import csv


def txt2csv_mag(file):
    file_name = "D:/lichee-temporary/csv/"+file.split('.')[0] + ".csv"
    csvFile = open(file_name,'w',newline='',encoding='utf-8')
    writer = csv.writer(csvFile)
    csvRow = []

    f = open("D:/lichee-temporary/test/"+file, 'r', encoding='GB2312')
    for line in f:
        csvRow = line.split()
        writer.writerow(csvRow)

    f.close()
    csvFile.close()
    print("txt转换csv成功")


if __name__ == '__main__':
    txt2csv_mag("20200619-cs4-2quan.txt")